<include file="Public/Header" />
<link type="text/css" rel="stylesheet" href="__CSS__/jquery-tag.css" />
<table width="100%" height="31px" border="0" cellpadding="0" cellspacing="0" class="left_topbg" id="table2">
      <tr>
        <td height="31">
			<div class="titlebt">
				<if condition="I('get.do')=='addGame'">
					添加游戏
				<else />
					修改游戏
				</if>
			</div>
		</td>
      </tr>
    </table>

<div class="main">

	<div class="form">
		<php>$do = I('get.do');</php>
		<form method='post' id="form_do" name="form_do" action="{:U('Game/Lists', 'do=' . $do)}">
			<input type="hidden" name="game_id" value="{$game.game_id}" />
		<dl>
			<dt> <span class="red">* </span>标题：</dt>
			<dd>
				<input type="text" name="game_name" class="inp_one" id="game_name" value="{$game.game_name}" placeholder="游戏名称" />
			</dd>
		</dl>

			<dl>
				<dt> <span class="red">* </span> 字母索引：</dt>
				<dd>
					<input type="text" name="initial" class="inp_one" id="fistname" value="{$game.game_name_initials}" placeholder="游戏名称首字母" />
				</dd>
			</dl>

			<dl>
				<dt> <span class="red">* </span> 充值类型：</dt>
				<dd>
					<select name="recharge" class="recharge" value="{$game.game_recharge_class}">
						<volist name="recharge_list" id="vo">
							<if condition="$game['game_recharge_class'] == $vo['common_class_id'] && $game['game_is_recharge'] == 1">
								<option value="{$vo.common_class_id}" selected="selected">{$vo.common_class_name}</option>
							<else />
								<option value="{$vo.common_class_id}">{$vo.common_class_name}</option>
							</if>

						</volist>
						<if condition="$game['game_is_recharge'] == 0">
							<php>$is_show_currency = ' style="display:none;"';</php>
							<option value="0" selected="selected">不允许充值</option>
						<else />
							<php>$is_show_currency = '';</php>
							<option value="0">不允许充值</option>
						</if>
					</select>
				</dd>
			</dl>
			<div class="game-currency"{$is_show_currency}>
				<dl>
					<dt> 游戏币名称：</dt>
					<dd>
						<input type="text" name="currency" class="inp_one currency" value="{$game.currency}" placeholder="元宝" />
					</dd>
				</dl>

				<dl>
					<dt> 兑换比例：</dt>
					<dd>
						<input type="text" name="ratio" class="inp_one ratio" value="{$game.ratio}" placeholder="通币:游戏币/1:100" />
					</dd>
				</dl>
			</div>
		<dl>
			<dt> <span class="red">* </span> 所属分类：</dt>
			<dd>
					<select id="select0">
						<volist name="gamefl" id="vo">
						<if condition="$vo['class_id'] == $game['class_parent_id']">
							<option value="{$vo.class_id}" class="selects" selected="selected">{$vo.class_name}</option>
						<else />
							<option value="{$vo.class_id}" class="selects">{$vo.class_name}</option>
						</if>
						</volist>
					</select>
					<select id="select1">
						<empty name="gamefl2">
							<option value="0" class="selects1">游戏类型</option>
						</empty>

						<volist name="gamefl2" id="vo">
							<if condition="$vo['class_id'] == $game['game_class_id']">
								<option value="{$vo.class_id}" class="selects1" selected="selected">{$vo.class_name}</option>
							<else />
								<option value="{$vo.class_id}" class="selects1">{$vo.class_name}</option>
							</if>
						</volist>
					</select>
				<input type="hidden" name="cid" id="category-id" value="{$game.game_class_id}" />
			</dd>
		</dl>

		<dl>
			<dt>游戏区服：</dt>
			<dd>
				<div class="plus-tag-add">
					<input type="text" class="inp_one" maxlength="20" placeholder="请添加" />
					<input type="button" class="btn_blue button" value="添加" />
				</div>
				<div class="plus-tag tagbtn clearfix" id="myTags">
					<volist name="servers" id="vo">
						<a title="{$vo.game_server_name}" value="{$vo.game_server_id}" href="javascript:void(0);"><span>{$vo.game_server_name}</span><em></em></a>
					</volist>
				</div>
			</dd>
		</dl>

		<div class="form_b">
			<input type="button" class="btn_blue" id="addGame" value="提 交">
		</div>
	   </form>
	</div>
</div>
<include file="Public/Copyright" />
<script type="text/javascript" src="__SCRIPT__/jquery-tag-select.js"></script>
<script type="text/javascript">
	$(function(){
        $('#game_name').blur(function(){
            $.ajax({
                type:'POST',
                url:"{:U('Game/fistName')}",
                data:{
                    name:$('#game_name').val()
                },
                success:function(response){
                    $('#fistname').val(response);
                }
            })
        })
		$('#select0').blur(function(){
			$.ajax({
				type:'POST',
				url:"{:U('Game/Lists', 'do=selectlist')}",
				data:{
					list1:$("#select0").val()
				},
				success:function(response,status,xhr){
					$("#select1").html("");
					$.each(response, function(i, item) {
						$("#select1").append(
								'<option value="'+item.class_id+'">'+item.class_name+'</option>'
						);
					});
				}
			});
		})

		$('#select1').blur(function(){
			var v = parseInt($(this).val());
			if( v > 0 )
				$('#category-id').val( v );
		});

		$('#select0').blur(function(){
			$('#category-id').val('');
		});
	})

	$('#addGame').click(function(){
		$('#form_do').submit();
	});


	$('.recharge').change(function(){
		var v = $(this).val();
		if( v == 0 ){
			$('.currency').val('');
			$('.ratio').val('');
			$('.game-currency').hide();
		}else{
			$('.game-currency').show();
		}
	});
</script>
</body>
</html>
